#include <stdio.h>
#include <map>
#include <algorithm>
#include <set>

struct Test {
    std::string sid;
    int a;
    int b;
    Test(std::string sid, int a, int b) : sid(sid), a(a), b(b) {}
    bool operator<(const Test& other) const
    {
        if (sid == other.sid) return false;

        if (a == other.a) return b > other.b;

        return a > other.a;
    }

    //bool operator==(const Test& other) const
    //{
        //return sid == other.sid;
    //}
};

int main(int argc, char **argv) {
    std::map<int, int, std::greater<int>> test;
    test.emplace(2,3);
    test.emplace(1,2);
    test.emplace(5,4);
    test.emplace(3,4);
    test.emplace(2,4);

    for (const auto& t : test) {
        printf("%d -> %d\n", t.first, t.second);
    }

    auto it = std::find_if(test.cbegin(), test.cend(), [] (const std::pair<int, int>& t) {
        return t.first < 4;
    });
    if (it != test.end())
        printf("find %d\n", it->first);

    std::set<Test> t;
    t.insert(Test("a", 1,2));
    t.insert(Test("a", 1,3));
    t.insert(Test("b", 3,2));
    t.insert(Test("b", 4,4));

    auto x = t.find(Test("a", 0, 0));
    printf("find %s -> %d, %d\n", x->sid.c_str(), x->a, x->b);
    for (const auto& x : t) {
        printf("%s -> %d, %d\n", x.sid.c_str(), x.a, x.b);
    }
    return 0;
}
